package com.mavenq.fly.business.service;

import com.mavenq.fly.business.PersonService;
import com.mavenq.fly.business.entity.Family;
import com.mavenq.fly.business.entity.Person;
import com.mavenq.fly.commons.resp.ResponseBuilder;
import com.mavenq.fly.commons.resp.ResponseObj;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Service
public class PersonServiceImpl implements PersonService {

    @Override
    public ResponseObj<List<Person>> getPersonList(Long familyId) throws ParseException {

        List<Person> personList = new ArrayList<>();
        personList.add(Person.builder()
                .id(1L)
                .name("褚鹏飞")
                .age(34)
                .birthday(new SimpleDateFormat("yyyy-MM-dd").parse("1989-01-17"))
                .family(Family.builder().id(familyId).address("河北省衡水市故城县").logo("www.mavenq.top").build())
                .hobbies(Arrays.asList("篮球","dota2","编程"))
                .build());

        personList.add(Person.builder()
                .id(2L)
                .name("褚曦月")
                .age(6)
                .birthday(new SimpleDateFormat("yyyy-MM-dd").parse("2017-08-11"))
                .family(Family.builder().id(familyId).address("河北省衡水市故城县").logo("").build())
                .hobbies(Arrays.asList("过亲家","玩手机","看电视"))
                .build());


        return new ResponseBuilder<List<Person>>()
                .buildCode(ResponseObj.SUC_CODE)
                .buildMsg(ResponseObj.SUC_MSG)
                .buildData(personList).build();

    }
}
